using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TextShining : MonoBehaviour
{
    // Start is called before the first frame update

    public TextMesh thisText;
    public float nowAlpha;
    public float shiningSpeed;
    public Color originalColor;
    public Color alphaColor;
    public bool startShining;

    void Start()
    {
        startShining = false;
        nowAlpha = 1f;
        shiningSpeed = -2f;
        alphaColor = originalColor;
        thisText = this.GetComponent<TextMesh>();

    }

    // Update is called once per frame
    void Update()
    {
        if (startShining)
        {
 
            nowAlpha += shiningSpeed * Time.deltaTime;
            if (shiningSpeed < 0 && nowAlpha <= 0)
            {
                shiningSpeed *= -1;
            }
            if (shiningSpeed > 0 && nowAlpha >= 1)
            {
                shiningSpeed *= -1;
            }
            alphaColor.a = nowAlpha;
            thisText.color = alphaColor;

        }
        else
        {
            thisText.color = originalColor;
        }

    }

}
